package com.application.adapter;


import android.widget.Toast;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.application.R;
import com.application.bean.NewsBean;

import java.util.List;

public class MyBaseQuickAdapter extends BaseQuickAdapter<NewsBean, BaseViewHolder> {


    public MyBaseQuickAdapter(List<NewsBean> data) {
        super(R.layout.list_item_layout, data);
        setOnItemClickListener((adapter, view, position) -> {
            Toast.makeText(getContext(),"你点击了"+(position+1),Toast.LENGTH_SHORT).show();
        });
    }


    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, NewsBean newsBean) {
        baseViewHolder.setText(R.id.tv_recycler_title,newsBean.getTitle());
        baseViewHolder.setText(R.id.tv_recycler_content,newsBean.getContent());
        baseViewHolder.setImageResource(R.id.iv_recycler_img,newsBean.getImageResourceId());

    }
}
